﻿using System;
using System.Data;
using System.Collections.Generic;
using System.Linq;
using System.Text;

using Microsoft.Practices.EnterpriseLibrary.Data;
using Enterprise.DataFactory;
using Enterprise.Model.Permission;
using Enterprise.Infrastructure;
namespace Enterprise.Data.Permission
{
    /// <summary>
    /// 权限按钮组别操作
    /// </summary>
    public class PermissionButtonData
    {
        /// <summary>
        ///  权限按钮组别数据列表
        /// </summary>
        /// <returns></returns>
        public List<PermissionButtonEntity> PermissionButtonList()
        {
            List<PermissionButtonEntity> list = new List<PermissionButtonEntity>();
            string cmd = "Select * from SYS_PERMISSIONBUTTON";
            IDataReader dr = DbExecute.DataReader(cmd);
            while (dr.Read())
            {
                PermissionButtonEntity entity = new PermissionButtonEntity();
                if (!Convert.IsDBNull(dr["PACTION"])) entity.PACTION = Convert.ToString(dr["PACTION"]);
                if (!Convert.IsDBNull(dr["PBNAME"])) entity.PBNAME = Convert.ToString(dr["PBNAME"]);
                if (!Convert.IsDBNull(dr["PBGROUP"])) entity.PBGROUP = Convert.ToString(dr["PBGROUP"]);
                if (!Convert.IsDBNull(dr["PORDER"])) entity.PORDER = Convert.ToInt32(dr["PORDER"]);
                if (!Convert.IsDBNull(dr["PCOMMENT"])) entity.PCOMMENT = Convert.ToString(dr["PCOMMENT"]);
                list.Add(entity);
            }
            dr.Close();
            return list;
        }

        /// <summary>
        /// 权限按钮组别数据操作方法
        /// </summary>
        /// <param name="cmd"></param>
        public void PermissionButtonExecute(string cmd)
        {
            DbExecute.Execute(cmd);
        }
    }
}
